package com.dgt.trade.controller;

import com.dgt.trade.dao.MessageDao;
import com.dgt.trade.entitys.Message_Quotation;
import com.dgt.trade.entitys.Message_System;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping(value = "message")
public class MessageController extends BaseController {

    @Autowired
    MessageDao messageDao;

    @RequestMapping(value = "/index")
    public ModelAndView getMessage(String id){
        ModelAndView view=new ModelAndView();
        if(id == null){
            id = "";
        }
        List<Message_Quotation> quotationList=messageDao.selectQuotationById("%"+id+"%");
        List<Message_System> systemList=messageDao.selectSystemById("%"+id+"%");
        if(quotationList != null && systemList != null){
            view.getModel().put("quotationList",quotationList);
            view.getModel().put("systemList",systemList);
            view.setViewName("trade/systerm_notice");
        }else{
            view.setViewName("error/404");
        }
        return view;
    }

}
